@use "sass:math";

@import '../../../stylesheets/colors';
@import '../../../stylesheets/variables';

.autocomplete-input__container {
  position: relative;
  width: 100%;
}

.autocomplete-input {
  width: 40vw;
  border: none;
  border-radius: 50px;
  color: rgba(0, 0, 0, 0);
}

.autocomplete-input,
.autocomplete-input__dummy-input {
  @include font-size-lg;
  padding: $global-spacing * 1.5 (25px + $global-spacing * 2) $global-spacing *
    1.5 $global-spacing * 3;
  font-family: $font-family-code;
  font-weight: $font-weight-thin;
  width: 100%;
  box-sizing: border-box;
  letter-spacing: -0.7px;
  margin: 0;

  @media screen and (max-width: 40em) {
    padding: $global-spacing (20px + $global-spacing) $global-spacing
      $global-spacing;
  }
}

.autocomplete-input__dummy-input {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
}

.dummy-input__package-name {
  color: #1d1d1d;
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

.dummy-input__package-version {
  color: #636363;
}

.dummy-input__at-separator {
  color: $pastel-green;
}

.autocomplete-input__suggestions-menu {
  border: 1px solid $autocomplete-border-color;
  border-top: 0;
  background: rgba(255, 255, 255, 0.96);
  font-size: 90%;
  position: absolute;
  overflow: auto;
  z-index: 10;
  max-height: 35vh;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  animation: unroll 0.2s cubic-bezier(0.305, 0.42, 0.205, 1.2);
  // align borders, negating nesting due to border on parent
  left: -1px;
  // hide rounded borders of the input
  margin-top: -5px;
  width: 100%;
  width: calc(100% + 2px);

  &:empty {
    border: 0;
  }
}

@keyframes unroll {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0px);
  }
}

.autocomplete-input__suggestion {
  padding: 10px 32px;
  color: #333;
  font-size: 15px;
  cursor: pointer;
  font-family: 'Source Code Pro', monospace;
  font-weight: $font-weight-light;
  letter-spacing: -0.5px;

  &:not(:last-of-type) {
    border-bottom: 1px solid #f5f5f5;
  }

  @media screen and (max-width: 40em) {
    padding: math.div($global-spacing, 1.5) $global-spacing * 1.5;
  }

  em {
    font-weight: $font-weight-bold;
    font-style: normal;
    color: #444;
  }
}

.autocomplete-input__suggestion--highlight {
  background: rgb(212, 243, 255);
}

.autocomplete-input__suggestion-description {
  @include font-size-xs;
  width: 100%;
  min-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: $font-family-body;
  font-weight: $font-weight-thin;
  color: #666;
  padding-top: 5px;
  letter-spacing: 0;

  @media screen and (max-width: 40em) {
    font-weight: $font-weight-light;
  }
}

.autocomplete-input__form {
  display: flex;
  align-items: baseline;
  position: relative;
}

.autocomplete-input__search-icon {
  position: absolute;
  right: $global-spacing * 2.5;
  z-index: 1;
  cursor: pointer;
  top: 0;
  bottom: 0;
  margin: auto;
  width: 25px;
  height: 25px;
  border: none;
  background: none;
  padding: 0;

  @media screen and (max-width: 40em) {
    width: 16px;
    height: 16px;
    right: $global-spacing * 1.5;
  }

  svg {
    width: 100%;
    height: 100%;

    path {
      transition: all 0.2s;
      fill: #666;
    }
  }

  &:hover {
    path {
      fill: $pastel-green;
      stroke: $pastel-green;
      stroke-width: 4px;
    }
  }
}
